<extend name="Public:common"/>
<block name="main">
    <form action="__APP__/Home/Find/index" class="am-form am-form-horizontal" method="post" data-am-validator="H5validation:false">
        <fieldset id="accordion">
        <legend data-am-collapse="{parent: '#accordion', target: '#do-not-say-1'}">查询账目</legend>
        <if condition="$ShowFind eq 1">
            <div id="do-not-say-1" class="am-collapse am-in">
        <else/>
            <div id="do-not-say-1" class="am-collapse">
        </if>
        <div class="am-input-group">
            <span class="am-input-group-label"><b>资金账户</b></span>
            <select id="select-funds" class="am-form-field" name="find_funds">
            <option value="">全部账户</option>
            <foreach name="FundsData" item="data">
              <option value="{$data.id}">{$data.name}</option>
            </foreach>
            </select>
            <span class="am-form-caret"></span>
        </div>
        <div><p></p></div>
        <div class="am-input-group">
            <span class="am-input-group-label"><b>收支类别</b></span>
            <select id="select-type" class="am-form-field" name="find_type">
                <option value="">全部类别</option>
                <option value="1">收入</option>
                <option value="2">支出</option>
                <option value="3">转账</option>
            </select>
            <span class="am-form-caret"></span>
        </div>
        <div><p></p></div>
        <div class="am-input-group">
            <span class="am-input-group-label"><b>选择分类</b></span>
            <select id="select-class" class="am-form-field" name="find_class" >
                <option value="">全部</option>
            </select>
        </div>
        <div><p></p></div>
        <div class="am-input-group">
            <span class="am-input-group-label"><b>起始时间</b></span>
            <input type="date" class="am-form-field" id="text-start-time" name="find_start_time" value="{$FindData.starttime}" />
        </div>
        <div><p></p></div>
        <div class="am-input-group">
            <span class="am-input-group-label"><b>终止时间</b></span>
            <input type="date" class="am-form-field" id="text-end-time" name="find_end_time"  value="{$FindData.endtime}" />
        </div>
        <div><p></p></div>
        <div class="am-input-group">
            <span class="am-input-group-label"><b>备注信息</b></span>
            <input type="text" class="am-form-field" id="text-mark" name="find_mark" value="{$FindData.acremark}" >
        </div>
        <p><input type="submit" class="am-btn am-btn-secondary am-btn-block" name="find_submit" value="查询"></p>
        </div>
        <p><a href="__APP__/Home/Find/reboot" class="am-btn am-btn-block am-btn-danger">重置</a></p>
        <p><a href="__APP__/Home/Index/index" class="am-btn am-btn-block am-btn-default">返回</a></p>
        </fieldset>
    </form>

    <div id="money-table" class="am-alert am-alert-secondary" data-am-alert>
        <button type="button" class="am-close">&times;</button>
        <p class="am-text-sm">
          收入:<font class="am-text-success money-format">{$SumInMoney}</font> &nbsp;
          支出:<font class="am-text-danger money-format" >{$SumOutMoney}</font> &nbsp;
          剩余:<font class="am-text-primary money-format">{$SumInMoney - $SumOutMoney}</font>
          <if condition="$isTransfer">
            <span class="am-badge am-badge-secondary am-round" style="margin-left: 6px;">含转账</span>
          <else/>
            <span class="am-badge am-round" style="margin-left: 6px;">不含转账</span>
          </if>
        </p>
    </div>
    
    <include file="Public:list_account"/>
    
</block>

<block name="javascript">
    <script type="text/javascript">
    function updataSelectClass(strOption) {
        $('#select-class option').remove();
        $("#select-class").append('<option value="">全部</option>');
        $("#select-class").append(strOption);
    }

    $(function(){
        $('#select-funds').change(function(){
            $('#select-type').val("");
            $('#select-type').trigger("change");
            $('#select-type option').remove();
            $("#select-type").append('<option value="">全部类别</option>');
            $("#select-type").append('<option value="1">收入</option>');
            $("#select-type").append('<option value="2">支出</option>');
            if ($('#select-funds').val() != "-1") {
                $("#select-type").append('<option value="3">转账</option>');
            }
        });
        if ("{$FindData.fid}" != "") {
            $("#select-funds").val("{$FindData.fid}");
            $('#select-funds').trigger("change");
        }
        if ("{$FindDataType}" != "") {
            $("#select-type").val("{$FindDataType}");
        }
        $('#select-type').change(function(){
            $('#select-class').val('');
            switch($('#select-type').val()) {
                case '1':
                    $('#select-class').parent().show();
                    updataSelectClass('<foreach name="inClassData" item="classname" key="classid" ><option value="{$classid}">{$classname}</option></foreach>');
                break;
                case '2':
                    $('#select-class').parent().show();
                    updataSelectClass('<foreach name="outClassData" item="classname" key="classid" ><option value="{$classid}">{$classname}</option></foreach>');
                break;
                case '3':
                    $('#select-class').parent().show();
                    updataSelectClass('<option value="inTransfer">转入</option><option value="outTransfer">转出</option>');
                break;
                default:
                    $('#select-class').parent().hide();
                    updataSelectClass({});
                break;
            }
        });
        $('#select-type').trigger("change");
        if ("{$FindDataClass}" != "") {
            $("#select-class").val("{$FindDataClass}");
        }
    });
    </script>
</block>